package util

import (
	"golang.org/x/net/html"
	"strings"
)

func FindAttribute(node *html.Node, key string) string {
	if node == nil || node.Attr == nil {
		return ""
	}

	key = strings.ToLower(key)

	for _, attribute := range node.Attr {
		if strings.ToLower(attribute.Key) == key {
			return attribute.Val
		}
	}

	return ""
}
